package com.rw.car.controller;

import com.rw.car.pojo.ConfigInfo;
import com.rw.car.service.ConfigInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author rabit
 */
@Controller
public class ViewController {

    @Autowired
    private ConfigInfoService configInfoService;


    @RequestMapping("{url}")
    public String getView(String url){
        System.out.println("ViewController.getView执行");
        return url;
    }
    @RequestMapping("/")
    public String getIndex(HttpServletRequest request){
        //加载配置
        String value =  configInfoService.getValueByKey("config_car_type");
        System.out.println(value);
        String[] values = value.split(",");
        request.getSession().setAttribute("config_car_type",values);
        System.out.println("ViewController.getIndex");
        return "index";
    }


}
